package com.yu.demo;

import org.assertj.core.util.Lists;

import java.util.ArrayList;
import java.util.List;

public class TreeCopy {

    public static int lengthOfLongestSubstring(String s) {
        if("".equals(s)){
            return 0;
        }else if(s.length()==1){
            return 1;
        }
        String[] group = s.split("");
        int groupLength = group.length;
        int resultSize = 0;
        for(int i=0;i<groupLength;i++){
            List<String> tempList = new ArrayList<String>();
            if((groupLength-i)<resultSize){
                break;
            }
            for(int j = i ; j<groupLength;j++){
                String str = group[j];
                if(tempList.contains(str)){
                    int tempSize = tempList.size();
                    if(tempSize>resultSize){
                        resultSize = tempSize;
                    }
                    tempList.clear();
                    tempList.add(str);
                }else{
                    tempList.add(str);

                }
            }
            int tempSize = tempList.size();
            if(tempSize>resultSize){
                resultSize = tempSize;
            }
        }
        return resultSize;
    }




    public static void main(String[] args) {
        List abc = Lists.newArrayList();
        int result = abc.size();
        System.out.println(result);
        abc.add("aa");
        System.out.println(result);
        System.out.println(lengthOfLongestSubstring("bwf"));
    }
}
